﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;

namespace happroject
{
    public partial class anadirNuevaTarea : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {

                ArrayList listaTareas = new ArrayList();

                
                Tarea nuevaTarea = new Tarea();

                nuevaTarea.prioridad = int.Parse(ddPrioridad.SelectedValue);
                nuevaTarea.descripcionTarea = tbDescripcionTarea.Text.ToString();
                nuevaTarea.longitudPomodorosTarea = int.Parse(ddPomodoroCty.SelectedValue);

                if (Session["listaDeTareas"] == null)
                {
                    Session["listaDeTareas"] = new ArrayList();
                }
                else
                {
                    listaTareas = (ArrayList)Session["listaDeTareas"];
                }



               // mejorar esto:
                if (listaTareas.Count == 0)
                {
                    nuevaTarea.wip = true;
                }
                listaTareas.Add(nuevaTarea);

                // posible solución:
                // http://msdn.microsoft.com/es-es/library/0e743hdt%28v=VS.90%29.aspx
       

                Session["listaDeTareas"] = listaTareas;
            }
            catch (Exception excepcion)
            {
                
            }


            Response.Write("<script language='javascript'> { window.close();}</script>");
        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            Response.Write("<script language='javascript'> { window.close();}</script>");
        }
    }
}